Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
How to satisfy "no-param-reassign"?

I have a list of items. Some have children and I need to mutate the object into a certain shape then return it. However, I'm getting a no-param-reassign error. Is there a better way I could go about this to prevent this error?

items.map(item => {
  if (item.child) {
    item.child = transformItem(item.child);
  }
});

return transformItem(result);

Edit to add whole function:

async getItemById(itemId: string) {
  try {
    const result = await this.connector.get(`/items/${itemId}/item`);
    items.map(item => {
      if (item.child) {
        item.child = transformItem(item.child);
      }
    });
    return transformItem(result);
  } catch (error) {
    throw new Error(error.message);
  }
}
const transformItem = item => ({
  id: item['id'],
  someItem: item['some_item'],
  ...
});

The purpose of transformItem is to convert all keys to camelCase instead of snake case. Perhaps there is a better way of going about this that'd prevent be from mutating it in place?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda